package com.honey.mybatis.generator;

import org.java.plugin.Plugin;

import com.honey.core.compiler.CompilationDescriptor;
import com.honey.core.compiler.ContentType;
import com.honey.core.compiler.CompilationType;
import com.honey.core.compiler.StorageType;
import com.honey.core.dbmapping.introspect.IntrospectSchema;
import com.honey.core.dbmapping.introspect.IntrospectSchemaColumn;
import com.honey.core.generator.CodeCompilation;
import com.honey.mybatis.generator.mappper.DynamicConditionMapper;
import com.honey.mybatis.generator.mappper.MybatisMapper;

public class MybatisMapperExtension extends AbstractMybatisExtension  implements  CodeCompilation{
	
	public MybatisMapperExtension(Plugin belongPlugin) {
		super(belongPlugin);
	}
	
	@Override
	public CompilationDescriptor[] compilation(IntrospectSchema introspectSchema,IntrospectSchemaColumn introspectSchemaColumn) {
		String workespace = mybatisPlugin.getProjectEnvironmentHolder().getTargetSrcDirectory();
		StorageType storageType = mybatisPlugin.getProjectEnvironmentHolder().getStorageType();
		String charset = mybatisPlugin.getProjectEnvironmentHolder().getCharset();
		return new CompilationDescriptor[]{
			new CompilationDescriptor(
				(new MybatisMapper(mybatisPlugin,introspectSchema,introspectSchemaColumn)).getDocument(), 
				workespace, 
				CompilationType.XML,
				storageType,
				ContentType.XML_MYBATIS_MAPPER_CONFIGURETION, 
				charset
			),
			new CompilationDescriptor(
				(new DynamicConditionMapper(mybatisPlugin,introspectSchema,introspectSchemaColumn)).getDocument(), 
				workespace, 
				CompilationType.XML,
				storageType,
				ContentType.XML_MYBATIS_MAPPER_CONFIGURETION, 
				charset
			)
		};
	}
	
	@Override
	public void clean() {
		
	}
}
